home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / libray / libtext / fbmbump.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-09  |  1.5 KB  |  60 lines

  1. /*
  2.  * fbmbump.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * fbmbump.c,v 4.1 1994/08/09 08:02:36 explorer Exp
  17.  *
  18.  * fbmbump.c,v
  19.  * Revision 4.1  1994/08/09  08:02:36  explorer
  20.  * Bump version to 4.1
  21.  *
  22.  * Revision 1.1.1.1  1994/08/08  04:52:14  explorer
  23.  * Initial import.  This is a prerelease of 4.0.6enh3, or 4.1 possibly.
  24.  *
  25.  * Revision 4.0  91/07/17  14:42:21  kolb
  26.  * Initial version.
  27.  * 
  28.  */
  29. #include "texture.h"
  30. #include "fbm.h"
  31. #include "fbmbump.h"
  32.  
  33. FBm *
  34. FBmBumpCreate(offset, scale, h, lambda, octaves)
  35. Float offset, h, lambda, scale;
  36. int octaves;
  37. {
  38.     FBm *fbm;
  39.     fbm = FBmCreate(offset, scale, h, lambda, octaves, 0., (char *)NULL);
  40.     return fbm;
  41. }
  42.  
  43. /*ARGSUSED*/
  44. void
  45. FBmBumpApply(fbm, prim, ray, pos, norm, gnorm, surf)
  46. FBm *fbm;
  47. Geom *prim;
  48. Ray *ray;
  49. Vector *pos, *norm, *gnorm;
  50. Surface *surf;
  51. {
  52.     Vector disp;
  53.  
  54.     VfBm(pos, fbm->omega, fbm->lambda, fbm->octaves, &disp);
  55.     norm->x += fbm->offset + disp.x * fbm->scale;
  56.     norm->y += fbm->offset + disp.y * fbm->scale;
  57.     norm->z += fbm->offset + disp.z * fbm->scale;
  58.     (void)VecNormalize(norm);
  59. }
  60.